import { Dayjs } from "dayjs";
import { CommonStatus } from "../../models";

export enum CompanyType {
  GeneralTaxpayer = "1",
  SmallScaleTaxpayers = "2",
  IndividualBusiness = "3",
  Personal = "4",
}

export interface SupplierItem {
  id: number;
  uscCode: string;
  name: string;
  mnemonicCode: string;
  adminRegionId: number | string;
  officeAddress: string;
  registerAddress: string;
  phone: string;
  email: string;
  fax: string;
  legalName: string;
  legalIdCard: string;
  bankName: string;
  bankNum: string;
  companyType: CompanyType;
  status: CommonStatus;
}

export interface AddressBookItem {
  id: number;
  supplierId: number;
  name: string;
  dept: string;
  post: string;
  phone: string;
  email: string;
  im: string;
}

export interface IdLicenseItem {
  id: number;
  supplierId: number;
  name: string;
  codeNum: string;
  validityPeriod: string;
  photo: string;
}

export interface WarehouseItem {
  id: number;
  parentId: number;
  name: string;
  location: string;
  area: string;
  children?: WarehouseItem[];
}

export interface TrainNumberItem {
  id: number;
  licensePlate: string;
  vehicleBrand: string;
  vehicleModel: string;
  vehicleType: string;
  vehicleSize: string;
  cargoCapacity: string;
  cargoWeight: string;
  mileageDriven: string;
}

export interface ProductFileItem {
  id: number;
  productId: number;
  supplierId: number | null;
  supplierName: string;
  productCode: string;
  productTypeId: number | null;
  productType: string;
  barCode: string;
  name: string;
  mallClass: string;
  mallClassId: number | null;
  productArea: string;
  specifications: string;
  measurementUnit: string | null;
  weight: string;
  validityCriteria: string;
  purchasePrice: number | null;
  price: number | null;
  wholesalePrice: number | null;
  taxRate: string;
  saveAs: string;
  status: number;
  pointRedemptionRatio: number | null;
  introduction: string;
  thumbnail: string;
  //
  goodsWarehousingId: number | null;
  orderQuantity: number | null;
  warehousingQuantity: number | null;
  shelfLife: number | null;
  _shelfLife: Dayjs | null;
  // manufactureDate: number | null;
  // _manufactureDate: Dayjs | null;
  productBatch: string;
  buyingPrice: number | null;
  warehousingAmount: number | null;
  //
  goodsDeliveryId: number | null;
  deliveryQuantity: number | null;
  amount: number | null;
  reason: string;
  //
  goodsReturnsId: number | null;
  returnsQuantity: number | null;
  discountAmount: number | null;
  returnsAmount: number | null;
  productDate: number | null;
  _productDate: Dayjs | null;
  //
  goodsAdjustmentId: number | null;
  adjustmentQuantity: number | null;
  //
  profitLossId: number | null;
  profitLossQuantity: number | null;
  profitLossAmount: number | null;
  //
  orderId: number | null;
  orderAmount: number | null;
  //
  goodsSaleId: number | null;
  saleQuantity: number | null;
}

export enum DeliveryType {
  front = 0,
  distribute = 1,
  sell = 2,
  return = 3,
}

export enum ProfitLossType {
  normal = 0,
  inventory = 1,
}

export enum AdjustmentType {
  normal = 0,
}

export enum PurchaseOrderType {
  normal = 0,
  forever = 1,
  cycle = 2,
}

export enum GoodsSaleType {
  normal = 0,
  batchSell = 1,
}

export interface ReceiptItem {
  id: number;
  warehousingNo: string;
  supplierId: number | null;
  supplierName: string | null;
  warehouse: string | null;
  warehouseId: number | null;
  warehouseAdmin: string;
  warehouseAdminId: number | null;
  warehousingDate: number | null | string;
  tabulationTime: number | null | string;
  tabulator: string;
  reviewTime: number;
  reviewer: string;
  status: ReceiptStatus;
  warehousingQuantity: number | null;
  warehousingAmount: number | null;
  remark: string;
  //
  details: Partial<ProductFileItem>[];
  batchDetails: Partial<ProductFileItem>[];
  //
  deliveryNo: string;
  deliveryType: null | DeliveryType;
  deliveryDate: number | null | string;
  deliveryQuantity: number | null;
  deliveryAmount: number | null;
  //
  returnsNo: string;
  returnsWarehouse: string | null;
  returnsWarehouseId: number | null;
  returnsDate: number | null | string;
  returnsQuantity: number | null;
  returnsAmount: number | null;
  saleOrderId: number | null;
  saleOrderNo: string;
  //
  adjustmentNo: string;
  adjustmentType: AdjustmentType | null;
  deliveryWarehouse: string | null;
  deliveryWarehouseId: number | null;
  deliveryAdmin: string;
  deliveryAdminId: number | null;
  receiveWarehouse: string | null;
  receiveWarehouseId: number | null;
  receiveAdmin: string;
  receiveAdminId: number | null;
  adjustmentDate: number | null | string;
  adjustmentQuantity: number | null;
  adjustmentAmount: number | null;
  //
  profitLossNo: string;
  profitLossType: ProfitLossType | null;
  profitLossDate: number | null | string;
  profitLossQuantity: number | null;
  profitLossAmount: number | null;
  //
  orderNo: string;
  orderType: PurchaseOrderType | null;
  orderQuantity: number | null;
  orderAmount: number | null;
  purchasingOfficer: string;
  purchasingOfficerId: number | null;
  //
  goodsSaleNo: string;
  goodsSaleType: GoodsSaleType | null;
  saleDate: number | null | string;
  saleQuantity: number | null;
  saleAmount: number | null;
  //relate
  purchaseOrderId: number;
  purchaseOrderNo: string;
  paymentReceiptId: number;
  paymentReceiptNo: string;
}

export enum ReceiptStatus {
  waiting = 0,
  passed = 1,
  disabled = 2,
  pushed = 3,
  confirmed = 4,
}

export const ReceiptStatusDetail = {
  [ReceiptStatus.waiting]: { text: "待审核", color: "#7B879A" },
  [ReceiptStatus.passed]: { text: "审核通过", color: "#4285F4" },
  [ReceiptStatus.disabled]: { text: "作废", color: "#F56662" },
  [ReceiptStatus.pushed]: { text: "推送中，待确认", color: "#4285F4" },
  [ReceiptStatus.confirmed]: { text: "确认成功", color: "#4285F4" },
};

export enum ReceiptType {
  /**
   * 入库
   */
  warehousing = "warehousing",
  /**
   * 商品出库
   */
  delivery = "delivery",
  /**
   * 商品退货 客户退回仓库
   */
  return = "return",
  /**
   * 商品调拨
   */
  adjustment = "adjustment",
  /**
   * 商品损益
   */
  profitLoss = "profitLoss",
  /**
   * 采购订单
   */
  purchase = "purchase",
  /**
   * 商品销售
   */
  sell = "sell",
}
